package com.bms.cfcmms.service;

import com.bms.cfcmms.dao.ModuleDao;
import com.bms.cfcmms.model.system.module.Module;
import com.bms.cfcmms.util.SysUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;

import javax.annotation.Resource;

/**
 * Created by carl on 2016/8/5.
 */
public class BaseService <T extends Serializable> {

    final Logger log = LoggerFactory.getLogger(BaseService.class);
    @Resource
    private ModuleDao moduleDao;

    public String makeId() {
        return RandomStringUtils.randomAlphanumeric(12);
    }

    public Module queryModule() {
        Class refClass = getClass();
        Object object = SysUtils.getClassObj(refClass);
        Class<T> tClass = (Class<T>)object;
        return moduleDao.queryForObjectByName(tClass.getSimpleName());
    }
}
